package tw.asap.plus.entity.response;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

/**
 * Description:
 * Created:      [15/12/29]
 * Author:       [Yang]
 **/
public class GoodsInfoNV implements Parcelable {

    /**
     * item_class : 分类名称
     * item_list : [{"img":"商品图片","tags":"店长推荐","price":"现价","title":"商品名称","price_init":"原价","sales_nums":"销售数量","id":"商品id","unit":"单位","props":[{"propkey_id":"商品属性id (int)","name":"商品属性名字, 如: 风味","values":[{"propvalue_id":"属性值id (int)","value":"商品属性值,　如: 加冰"}]}]}]
     */

    private String item_class;
    /**
     * img : 商品图片
     * tags : 店长推荐
     * price : 现价
     * title : 商品名称
     * price_init : 原价
     * sales_nums : 销售数量
     * id : 商品id
     * unit : 单位
     * props : [{"propkey_id":"商品属性id (int)","name":"商品属性名字, 如: 风味","values":[{"propvalue_id":"属性值id (int)","value":"商品属性值,　如: 加冰"}]}]
     */

    private List<ItemListEntity> item_list;

    public void setItem_class(String item_class) {
        this.item_class = item_class;
    }

    public void setItem_list(List<ItemListEntity> item_list) {
        this.item_list = item_list;
    }

    public String getItem_class() {
        return item_class;
    }

    public List<ItemListEntity> getItem_list() {
        return item_list;
    }

    public GoodsInfoNV() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.item_class);
        dest.writeTypedList(item_list);
    }

    protected GoodsInfoNV(Parcel in) {
        this.item_class = in.readString();
        this.item_list = in.createTypedArrayList(ItemListEntity.CREATOR);
    }

    public static final Creator<GoodsInfoNV> CREATOR = new Creator<GoodsInfoNV>() {
        public GoodsInfoNV createFromParcel(Parcel source) {
            return new GoodsInfoNV(source);
        }

        public GoodsInfoNV[] newArray(int size) {
            return new GoodsInfoNV[size];
        }
    };


    public static class ItemListEntity implements Parcelable {

        private String img;
        private String tags;
        private String price;
        private String title;
        private String price_init;
        private String sales_nums;
        private String id;
        private String unit;
        /**
         * propkey_id : 商品属性id (int)
         * name : 商品属性名字, 如: 风味
         * values : [{"propvalue_id":"属性值id (int)","value":"商品属性值,　如: 加冰"}]
         */

        private List<PropsEntity> props;

        public void setImg(String img) {
            this.img = img;
        }

        public void setTags(String tags) {
            this.tags = tags;
        }

        public void setPrice(String price) {
            this.price = price;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public void setPrice_init(String price_init) {
            this.price_init = price_init;
        }

        public void setSales_nums(String sales_nums) {
            this.sales_nums = sales_nums;
        }

        public void setId(String id) {
            this.id = id;
        }

        public void setUnit(String unit) {
            this.unit = unit;
        }

        public void setProps(List<PropsEntity> props) {
            this.props = props;
        }

        public String getImg() {
            return img;
        }

        public String getTags() {
            return tags;
        }

        public String getPrice() {
            return price;
        }

        public String getTitle() {
            return title;
        }

        public String getPrice_init() {
            return price_init;
        }

        public String getSales_nums() {
            return sales_nums;
        }

        public String getId() {
            return id;
        }

        public String getUnit() {
            return unit;
        }

        public List<PropsEntity> getProps() {
            return props;
        }


        public ItemListEntity() {
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(this.img);
            dest.writeString(this.tags);
            dest.writeString(this.price);
            dest.writeString(this.title);
            dest.writeString(this.price_init);
            dest.writeString(this.sales_nums);
            dest.writeString(this.id);
            dest.writeString(this.unit);
            dest.writeTypedList(props);
        }

        protected ItemListEntity(Parcel in) {
            this.img = in.readString();
            this.tags = in.readString();
            this.price = in.readString();
            this.title = in.readString();
            this.price_init = in.readString();
            this.sales_nums = in.readString();
            this.id = in.readString();
            this.unit = in.readString();
            this.props = in.createTypedArrayList(PropsEntity.CREATOR);
        }

        public static final Creator<ItemListEntity> CREATOR = new Creator<ItemListEntity>() {
            public ItemListEntity createFromParcel(Parcel source) {
                return new ItemListEntity(source);
            }

            public ItemListEntity[] newArray(int size) {
                return new ItemListEntity[size];
            }
        };
    }

    public static class PropsEntity implements Parcelable {
        private String propkey_id;
        private String name;
        /**
         * propvalue_id : 属性值id (int)
         * value : 商品属性值,　如: 加冰
         */

        private List<ValuesEntity> values;

        public void setPropkey_id(String propkey_id) {
            this.propkey_id = propkey_id;
        }

        public void setName(String name) {
            this.name = name;
        }

        public void setValues(List<ValuesEntity> values) {
            this.values = values;
        }

        public String getPropkey_id() {
            return propkey_id;
        }

        public String getName() {
            return name;
        }

        public List<ValuesEntity> getValues() {
            return values;
        }

        public PropsEntity() {
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(this.propkey_id);
            dest.writeString(this.name);
            dest.writeTypedList(values);
        }

        protected PropsEntity(Parcel in) {
            this.propkey_id = in.readString();
            this.name = in.readString();
            this.values = in.createTypedArrayList(ValuesEntity.CREATOR);
        }

        public static final Creator<PropsEntity> CREATOR = new Creator<PropsEntity>() {
            public PropsEntity createFromParcel(Parcel source) {
                return new PropsEntity(source);
            }

            public PropsEntity[] newArray(int size) {
                return new PropsEntity[size];
            }
        };
    }

    public static class ValuesEntity implements Parcelable {
        private String propvalue_id;
        private String value;

        public void setPropvalue_id(String propvalue_id) {
            this.propvalue_id = propvalue_id;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public String getPropvalue_id() {
            return propvalue_id;
        }

        public String getValue() {
            return value;
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(this.propvalue_id);
            dest.writeString(this.value);
        }

        public ValuesEntity() {
        }

        protected ValuesEntity(Parcel in) {
            this.propvalue_id = in.readString();
            this.value = in.readString();
        }

        public static final Creator<ValuesEntity> CREATOR = new Creator<ValuesEntity>() {
            public ValuesEntity createFromParcel(Parcel source) {
                return new ValuesEntity(source);
            }

            public ValuesEntity[] newArray(int size) {
                return new ValuesEntity[size];
            }
        };
    }
}
